/*
	       File: Debug.cs
	Create Date: 2007-10-25
	    Version:

	Description:


	 Change log:


*/
using System;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.Collections;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Workflow.ComponentModel;
using System.Workflow.ComponentModel.Design;
using System.Workflow.ComponentModel.Compiler;
using System.Workflow.ComponentModel.Serialization;
using System.Workflow.Runtime;
using System.Workflow.Activities;
using System.Workflow.Activities.Rules;

using GuerillaProgrammer.Components;
using GuerillaProgrammer.Components.Logging;
using GuerillaProgrammer.FileProcessor.Settings;
using GuerillaProgrammer.FileProcessor;

namespace GuerillaProgrammer.FileProcessor.Activities
{
    public class DebugTrace : Activity
    {
        #region Private member fields
        #endregion

        #region Constructors and cleanup methods
        #endregion

        #region Private implementation methods
        #endregion

        #region Class properties
        #endregion

        #region Events handlers
        protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
            Logger.LogEnter();
            IProcessorDataService dataService = executionContext.GetService(typeof(IProcessorDataService)) as IProcessorDataService;
            if (null == dataService)
            {
                throw new InvalidOperationException("Can't get the service!");
            }

            WorkItem workItem = dataService.GetWorkItem();
            /*
                The trace message will look like:
                Grinder Trace - WorkItem information
                Processing time: yyyyMMdd hhmmss
                DirectoryID: 
                FileTypeID:
                Filename: 
                
            */
            string message = string.Format("Grinder Trace - WorkItem information\nProcessing time: {0}\nDirectory ID: {1}\nFiletype ID: {2}\nFilename: {3}\n",DateTime.Now.ToString("yyyyMMdd hhmmss"),workItem.DirectoryID, workItem.Filename, workItem.FileTypeID);
            Trace.Write(message);
            Logger.LogLeave();
            return base.Execute(executionContext);
        }
        #endregion

        #region Public interface
        #endregion
    }
}
